<html>
<head>
    <meta charset="UTF-8">

</head>
<body>
    <button onclick="setValue()">设置值</button>
<button onclick="getValue()">获取值</button>

<div id="v"></div>
</body>
<script>

    function setValue(){
        localStorage.setItem("ab" , "hello world");
    }
    function getValue(){
        var val = localStorage.getItem("ab");
        document.getElementById("v").innerText = val;
    }
</script>
</html>